package com.xing.service.impl;

import com.xing.dao.SystemUserMapper;
import com.xing.entity.pojo.SystemUser;
import com.xing.service.SystemUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,readOnly = false)
public class SystemUserServiceImpl implements SystemUserService {
    @Autowired
    private SystemUserMapper systemUserMapper;
    @Override
    public int deleteByPrimaryKey(String userId) {
        return systemUserMapper.deleteByPrimaryKey(userId);
    }

    @Override
    public int insert(SystemUser record) {
        return systemUserMapper.insert(record);
    }

    @Override
    public int insertSelective(SystemUser record) {
        return systemUserMapper.insertSelective(record);
    }

    @Override
    public SystemUser selectByPrimaryKey(String userId) {
        return systemUserMapper.selectByPrimaryKey(userId);
    }

    @Override
    public int updateByPrimaryKeySelective(SystemUser record) {
        return systemUserMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(SystemUser record) {
        return systemUserMapper.updateByPrimaryKey(record);
    }

    @Override
    public SystemUser findByName(String name) {
        return systemUserMapper.findByName(name);
    }

    @Override
    public SystemUser findUserAll(SystemUser user) {
        return systemUserMapper.findUserAll(user);
    }

    @Override
    public List<SystemUser> findAll(SystemUser systemUser) {
        return systemUserMapper.findAll(systemUser);
    }

    @Override
    public Boolean deleteSelectedUser(String[] ids) {
        boolean flag=false;
        for (String id : ids) {
            int i1 = systemUserMapper.deleteByPrimaryKey(id);
            flag = i1 > 0;
        }
        return flag;
    }

    @Override
    public List<SystemUser> findByRoleId(String roleId) {
        return systemUserMapper.findByRoleId(roleId);
    }

    @Override
    public void updateRoleId(String roleId, String UserId) {
        systemUserMapper.updateRoleId(roleId, UserId);
    }
}
